package xinxin.com.MementoPattern;

import xinxin.com.MementoPattern.Caretaker.RoleStateCaretaker;
import xinxin.com.MementoPattern.Role.GameRole;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/3/28 13:14
 */
public class MementoPattern {
    public static void main(String[] args) {
        GameRole gameRole = new GameRole();
        gameRole.GetInitState();
        gameRole.stateDisplay();

        // 保存进度
        RoleStateCaretaker stateCaretaker = new RoleStateCaretaker();
        stateCaretaker.setMemento(gameRole.saveState());

        // 大战Boss时，损耗严重
        gameRole.Fight();
        gameRole.stateDisplay();

        // 恢复之前的状态
        gameRole.recoveryState(stateCaretaker.getMemento());
        gameRole.stateDisplay();
    }
}
